var xmlhttp;

function getXmlHttpObject()
{
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return xmlhttp;
}

function setUpdateTime(type)
{
	getXmlHttpObject();
	var timestamp;
	var content;
	if(type == 1){
		timestamp = document.getElementById("ibtupdate").value;
		content = document.getElementById("ibtContent").value;
	}
	else if(type == 2){

		timestamp = document.getElementById("gmatupdate").value;
		content = document.getElementById("gmatContent").value;
	}
	else if(type == 3){

		timestamp = document.getElementById("greupdate").value;
		content = document.getElementById("greContent").value;
	}
	var url = "../controllers/setUpdateTime.php";
	params = "timestamp=" + timestamp + "&type=" + type + "&content=" + content;
	
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange = setUpdateTimeSuccess;
	xmlhttp.send(params);
	
}

function setUpdateTimeSuccess() {
	if (xmlhttp.readyState == 4)
		if (xmlhttp.status == 200)
		{
			var responseText = xmlhttp.responseText;
			alert(responseText);
			location.reload();
		}
	    else if (request.status == 404)
	        alert("请求的链接不存在");
	    else
	        alert("错误: 错误代码 " + xmlhttp.status);
}
